package com.chenyaowei.web.controller.product.spu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chenyaowei.common.annotation.Log;
import com.chenyaowei.common.core.controller.BaseController;
import com.chenyaowei.common.core.domain.AjaxResult;
import com.chenyaowei.common.enums.BusinessType;
import com.chenyaowei.product.domain.CywProSpuCommentReply;
import com.chenyaowei.product.service.ICywProSpuCommentReplyService;
import com.chenyaowei.common.utils.poi.ExcelUtil;
import com.chenyaowei.common.core.page.TableDataInfo;

/**
 * 商品评价回复Controller
 *
 * @author 陈耀威
 * @date 2023-12-03
 */
@RestController
@RequestMapping("/product/spuCommentReply")
public class CywProSpuCommentReplyController extends BaseController
{
    @Autowired
    private ICywProSpuCommentReplyService cywProSpuCommentReplyService;

    /**
     * 查询商品评价回复列表
     */
//    @PreAuthorize("@ss.hasPermi('product:spuCommentReply:list')")
    @GetMapping("/list")
    public TableDataInfo list(CywProSpuCommentReply cywProSpuCommentReply)
    {
        startPage();
        List<CywProSpuCommentReply> list = cywProSpuCommentReplyService.selectCywProSpuCommentReplyList(cywProSpuCommentReply);
        return getDataTable(list);
    }

    /**
     * 导出商品评价回复列表
     */
    @PreAuthorize("@ss.hasPermi('product:spuCommentReply:export')")
    @Log(title = "商品评价回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CywProSpuCommentReply cywProSpuCommentReply)
    {
        List<CywProSpuCommentReply> list = cywProSpuCommentReplyService.selectCywProSpuCommentReplyList(cywProSpuCommentReply);
        ExcelUtil<CywProSpuCommentReply> util = new ExcelUtil<CywProSpuCommentReply>(CywProSpuCommentReply.class);
        util.exportExcel(response, list, "商品评价回复数据");
    }

    /**
     * 获取商品评价回复详细信息
     */
//    @PreAuthorize("@ss.hasPermi('product:spuCommentReply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cywProSpuCommentReplyService.selectCywProSpuCommentReplyById(id));
    }

    /**
     * 新增商品评价回复（CywOrderItemController）
     */
/*    @PreAuthorize("@ss.hasPermi('product:spuCommentReply:add')")
    @Log(title = "商品评价回复", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CywProSpuCommentReply cywProSpuCommentReply)
    {
        return toAjax(cywProSpuCommentReplyService.insertCywProSpuCommentReply(cywProSpuCommentReply));
    }*/

    /**
     * 修改商品评价回复
     */
    @PreAuthorize("@ss.hasPermi('product:spuCommentReply:edit')")
    @Log(title = "商品评价回复", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CywProSpuCommentReply cywProSpuCommentReply)
    {
        return toAjax(cywProSpuCommentReplyService.updateCywProSpuCommentReply(cywProSpuCommentReply));
    }

    /**
     * 删除商品评价回复
     */
//    @PreAuthorize("@ss.hasPermi('product:spuCommentReply:remove')")
    @Log(title = "商品评价回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cywProSpuCommentReplyService.deleteCywProSpuCommentReplyByIds(ids));
    }
}
